;
(function($) {
	"use strict";

	(function() { // IE7-8实现before、after伪元素效果
		var obj = null;

		var _before = function(self, content) {
			obj = $("<i>").html(content);
			self.prepend(obj);
			obj = null;
		}

		var _after = function(self, content) {
			obj = $("<i>").html(content);
			self.append(obj);
			obj = null;
		}

		// 实现"圆心"效果
		if (!document.addEventListener) {
			_before($(".express_detaiL_info li"), "●");
		}
	})();

	(function() {
		var len = $(".express_detaiL_info").find("li").length;
		if (len > 4) {
			$(".express_detail_toolbar").data("show", true).show();
			$(".express_detaiL_info li").hide();
			$(".express_detaiL_info li:nth-child(-n + 4)").show();
		} else {
			$(".express_detail_toolbar").remove();
		}
	})();

	$(".express_toolbar_main").on("click", function(e) {
		var bFlag = $(".express_detail_toolbar").data("show");
		toggleExpressState(bFlag);

		$(".express_detail_toolbar").data("show", !bFlag);
	});

	function toggleExpressState(flag) {
		var sText = "";

		if (flag) {
			sText = "收起";
			$(".express_toolbar_main i").removeClass("express_icon_down").addClass("express_icon_up");
			$(".express_detaiL_info li").show();
		} else {
			sText = "展开查看全部";
			$(".express_toolbar_main i").removeClass("express_icon_up").addClass("express_icon_down");

			$(".express_detaiL_info li").hide();
			$(".express_detaiL_info li:nth-child(-n + 4)").show();
		}

		$(".express_toolbar_main label").text(sText);
	}

	var j_consult = $(".j_consult"),
		ticket = $(".ticket"),
		j_return = $(".j_return"),
		returns = $(".returns"),
		click_return = $(".return a"),
		good_return = $('.dialog_return');


	click_return.on("click", function() {
		ECar.modal.otherTemplate({
			template: good_return.show(),
			maskAlphaColor: "#fff",
			maskAlpha: "1",
			width: 688,
			height: 585,
			title: "申请退货",
			loadFn: function() {
				$(".back_reason_list").on("change", function(e){
					var sVal = $(this).val();
					switch(sVal) {
						case "01": 
							$(".back_reason_error").show();
							$(".back_reason_text").hide();
							break;
						case "07":
							$(".back_reason_error").show();
							$(".back_reason_text").val("").show();
							break;
						default:
							$(".back_reason_error").hide();
							$(".back_reason_text").hide();
					}
				});
				$(".back_reason_text").on("change", function(e){
					if($.trim($(this).val().length)) {
						$(".back_reason_error").hide();
					}
				});
			},
			closeFn: function() {
				ticket.hide();
			}
		});
	});

	j_consult.on("click", function() {
		ECar.modal.otherTemplate({
			template: ticket.show(),
			maskAlphaColor: "#000",
			maskAlpha: "1",
			width: 620,
			height: 585,
			title: "查看券码",
			closeFn: function() {
				ticket.hide();
			}
			// loadFn: function() {
			// 	var listScroller = ECar.imitatescroll({
			// 		id: "#DealerList"
			// 	});
			// }
		});
	});

	j_return.on("click", function() {
		ECar.modal.otherTemplate({
			template: returns.show(),
			maskAlphaColor: "#000",
			maskAlpha: "1",
			width: 690,
			height: 616,
			title: "查看退货",
			closeFn: function() {
				returns.hide();
			}
			// loadFn: function() {
			// 	var listScroller = ECar.imitatescroll({
			// 		id: "#DealerListone"
			// 	});
			// }
		});
	});

})(jQuery);